$.ajax({
    url: '/users_list.action',

    type:"POST",
    dataType:"JSON",
    success: function(result){

        function userlist(result){
            var slong = '';
            for(var i=0;i<result.data.length;i++){
                // var obj = JSON.parse(result[i]);
                slong = slong + '<tr>\n' +
                    // '<td>\n' +
                    // '<div class="layui-unselect layui-form-checkbox" lay-skin="primary" data-id=\'2\'><i class="layui-icon">&#xe605;</i></div>\n' +
                    // '</td>\n' +
                    // '<td>'+result.data[i].id+'</td>\n' +
                    '<td>'+result.data[i].usernumber+'</td>\n' +
                    '<td>'+result.data[i].realname+'</td>\n' +
                    '<td>'+result.data[i].jurisdiction+'</td>\n' +
                    '<td class="td-manage">\n' +
                    '<a title="删除" onclick="user_del(this)" href="javascript:;">\n' +
                    '<i class="layui-icon">&#xe640;</i>\n' +
                    '</a>\n' +
                    '</td>\n' +
                    '</tr>';
            }
            document.getElementById("userlisttbody").innerHTML = slong;
        }
        userlist(result);

    },
    error: function() {
        alert("错误提示： " + xhr.status + " " + xhr.statusText);
    },
});



function user_add(){
    var userrole=document.getElementById('user_role');
    var role = userrole.getElementsByTagName('input');
    for(var i=0;i<role.length;i++){
        if(role[i].checked){
            var userrole_value=role[i].value;
        }
    }
    var usernumber= document.getElementById('usernumber').value;

    var realname = document.getElementById('realname').value;
    var email =document.getElementById('email').value;


    var password =document.getElementById('password').value;

    $.ajax({
        url: '/users_add.action',
        /*/users_*.action(*的内容为list/add/del)*/
        data: {
            "usernumber": usernumber,
            "Realname": realname,
            "email": email,
            "role": userrole_value,
            "password": password
        },
        type: "POST",
        dataType: "JSON",
        success: function () {
            alert("添加成功");
        },
        error: function() {
            alert("错误");
        }
    });}

function user_del(obj) {
    var td = obj.parentNode;
    var index=td.parentNode.rowIndex;
    var user_list = document.getElementById("user_list");
    var number = user_list.rows[index].cells[0].innerHTML;
    user_list.deleteRow(index);
    $.ajax({
        url: '/users_del.action',
        /*/users_*.action(*的内容为list/add/del)*/
        data: {
            "usernumber": number,
        },
        type: "POST",
        dataType: "JSON",
        success: function () {
            alert("删除成功");
        },
        error: function() {
            alert("删除错误");
        }
    });}